package demo.jwt;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public  class JwtTokenInterceptorConfig implements WebMvcConfigurer  {
	
	 private final JwtTokenInterceptor jwtTokenInterceptor;

	    public JwtTokenInterceptorConfig(){
	        this.jwtTokenInterceptor = new JwtTokenInterceptor();
	    }

	    @Override
	    public void addInterceptors(InterceptorRegistry registry){
	        List<String> excludePath = new ArrayList<>();
	        
	        excludePath.add("/jwt/login");  

	        registry.addInterceptor(jwtTokenInterceptor)
	                .addPathPatterns("/jwt/**")
	                .excludePathPatterns(excludePath);
	        WebMvcConfigurer.super.addInterceptors(registry);

	    }
}